using System;
using System.Collections.Generic;

namespace Aima.Core.Util.datastructure
{
	// Provides a hash map which is indexed by a pair containing the two keys. 
	public class TwoKeyHashMap<TK1, TK2, TV> : Dictionary<Tuple<TK1, TK2>, TV>
	{
		
		// Associates the specified value with the specified key pair in this map.
	    public void Add(TK1 key1, TK2 key2, TV value)
		{
			Add(new Tuple<TK1, TK2>(key1, key2), value);
		}

		//  Returns the value to which the specified key pair is mapped 
        // TODO: override dictionary indexer ?
		public TV Get(TK1 key1, TK2 key2)
		{
			return base[new Tuple<TK1, TK2>(key1, key2)];
		}

		// Returns <code>true</code> if this map contains a mapping for the specified key pair.
		public bool ContainsKey(TK1 key1, TK2 key2)
		{
			return ContainsKey(new Tuple<TK1, TK2>(key1, key2));
		}

		// Removes the mapping for this key pair from this map if present.
		public TV Remove(TK1 key1, TK2 key2)
		{
			var keys = new Tuple<TK1, TK2>(key1, key2);
			TV val = base[keys];
			Remove(keys);
			return val;
		}

	  
	}
}